package com.jk1.bianligou.blg.utils;

import com.jk1.bianligou.blg.common.ErrorCode;
import com.jk1.bianligou.blg.exception.BizException;

/**
 * @author WHH
 */
public class ThrowUtils {


    public static void throwIfParamsIsNull(Object... params) {
        for (Object param : params) {
            if (param == null) {
                throw new BizException(ErrorCode.PARAMS_ERROR, "参数为空");
            }
        }
    }

    public static void throwSystemErrorIf(boolean condition) {
        if (condition) {
            throw new BizException(ErrorCode.SYSTEM_ERROR, "参数为空");
        }
    }

    public static void throwSystemErrorIf(boolean condition, String message) {
        if (condition) {
            throw new BizException(ErrorCode.SYSTEM_ERROR, message);
        }
    }

    public static void throwNoAuthIf(boolean condition) {
        if (condition) {
            throw new BizException(ErrorCode.NO_AUTH_ERROR);
        }
    }

    public static void throwIfNotLogin() {
        throw new BizException(ErrorCode.NOT_LOGIN_ERROR);
    }

}
